jQuery(document).ready(function(){
//	jQuery(".pfs-post-link").click(function(){
//		var $box = jQuery(this).siblings('div');
//		if ('relative' == jQuery(this).parents('article').css('position')) {
//			var top = 0;
//			var diff = jQuery(this).parents('article').offset();
//			var left = ( jQuery(window).width() - $box.width() )/2 - diff.left;	
//		} else {
//			var top = 90;
//			var left = ( jQuery(window).width() - $box.width() )/2;
//		}
//		if (top<0) top = 50;
//		$box.css({top:top+"px",left:left+"px"}).show();
//	});
//	jQuery(".closex").click(function(){
//		jQuery(this).parent().hide();
//	});
    jQuery("form.pfs").submit(function() {
        jQuery(this).ajaxSubmit({
            type: "POST",
            url: jQuery(this).attr('action'),
            dataType:'json',
            beforeSend: function(){
                jQuery('form.pfs #post').val('posting...');
                jQuery('form.pfs input, form.pfs textarea').attr('disabled','disabled');
            },
            error:function(){
                jQuery('form.pfs input, form.pfs textarea').removeAttr('disabled');
                jQuery('form.pfs #post').val('Post');
            },
            complete: function(request,textStatus,error) {
                jQuery('form.pfs #post').val('Post');
                data = jQuery.parseJSON(request.responseText);
                jQuery('form.pfs input, form.pfs textarea').removeAttr('disabled');
                if (data && data.error) {
                	//alert(data);
                    jQuery('.pfs-alert').addClass('error').html('<p>'+data.error+'</p>').show();
                } else {
                    jQuery('form.pfs').reset();
                    var value = '<p style="padding: 10px;line-height: 1.5em;">Thanks for Sharing! Your post will be displayed after a quick review, normally in less than 24 hours :) Thank you very much!</p><INPUT class="refresh_button" TYPE="button" onClick="history.go(0);" VALUE="Refresh and go back to the page." />';
                    $.colorbox({html:value,width:"50%",fixed:true, overlayClose: false});
//                    $.fn.colorbox.close();
//                    showMessage('success','Thank you for taking the time and providing us the information.  The news will be displayed after a quick review. However, if there is anything very urgent, please contact us at: 9843743381 or 9841766465.');
                    //location.reload();
                }
            }
        });
        return false;
    });
});
